<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .table{
            width:500px;
            overflow: auto;
        }
        table {
            table-layout: fixed;
            width: 200px; /* 固定宽度 */
        }
        td,
        th {
            /* 设置td,th宽度高度 */
            border: 1px solid gray;
            width: 100px;
            height: 30px;
        }
        th {
            background-color: lightblue;
        }
        th:first-child,td:first-child{
            position:sticky;
            left:0;
            background: #ccc;
        }
        th:nth-child(2),td:nth-child(2){
            position:sticky;
            left:100px;
            background: #ccc;
        }
        th:last-child,td:last-child{
            position:sticky;
            right:0;
            background: #ccc;
        }
    </style>
</head>
<body>
    <div class="table">
        <table>
            <thead>
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>